package com.woniuxy.config;


import com.woniuxy.dao.CampRepo;
import com.woniuxy.service.CampService;
import com.woniuxy.vo.CampVO;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class InitConifg implements InitializingBean {
    @Resource
    private CampRepo campRepo;
    @Resource
    private CampService campService;
    /*
     *  初始化的时候，将数据库信息加入elasticsearch中
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        List<CampVO> camps = campService.selectAllCampVO();
        campRepo.saveAll(camps);
    }
}
